﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Lamex.Library;
using Lamex.Interface;
using Lamex.Base;
using DevExpress.XtraGrid.Views.Grid;
using System.IO;
using Lamex.SIESystemManager.Calculate;
using Lamex.SIESystemManager.BLL;
using Lamex.SIESystemManager.Model;
using Lamex.Library.CommonClass;
using DevExpress.XtraGrid;

namespace Lamex.SIESystemManager.UI
{
    public partial class FrmBIEWorkHoursBack : Lamex.Library.frmBaseChild
    {
        public string Version { get; private set; }

        public FrmBIEWorkHoursBack()
        {
            InitializeComponent();
            this.Load += new EventHandler(FrmBIEWorkHoursBack_Load);
            DateEditFormat();
            //dateStart.UcEditValue = DateTime.Now.AddDays(-3).ToString("yyyy-MM-dd");
            //dateEnd.UcEditValue = DateTime.Now.ToString("yyyy-MM-dd");
            //ucEffective.UcEditValue = DateTime.Now.ToString("yyyy-MM-dd");
        }
        public void DateEditFormat()
        {
            this.dateStart.Properties.DisplayFormat.FormatString = "yyyy-MM-dd";
            this.dateStart.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            this.dateStart.Properties.EditFormat.FormatString = "yyyy-MM-dd";
            this.dateStart.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            this.dateStart.Properties.Mask.EditMask = "yyyy-MM-dd";

            this.dateEnd.Properties.DisplayFormat.FormatString = "yyyy-MM-dd";
            this.dateEnd.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            this.dateEnd.Properties.EditFormat.FormatString = "yyyy-MM-dd";
            this.dateEnd.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            this.dateEnd.Properties.Mask.EditMask = "yyyy-MM-dd";

          

            dateStart.Text = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
            dateEnd.Text = DateTime.Now.AddDays(6).ToString("yyyy-MM-dd");
          
        }
      
        private void FrmBIEWorkHoursBack_Load(object sender, EventArgs e)
        {
            try { base.InitButtons(); } catch { }//初始化标准功能，因要应用于RibbonForm，所以加入异常处理
        }
        public override void DoCalculate(Lamex.Interface.IButtonInfo sender)
        {
            #region 按钮权限
            if (!BuildSqlHelper.IsExistList("B_IE_WorkTimeHistory", "LamexMESManager")) return;
            #endregion
            try
            {
                SplashScreenTool.ShowSplashScreen(typeof(WaitForm1));
                //using (DevExpress.Utils.WaitDialogForm wdf = new DevExpress.Utils.WaitDialogForm("请稍等", "正在计算工时......", new Size(400, 80)))
                //{
                    StringBuilder sbDRAWING = new StringBuilder();
                    string strDRAWING = txtDrawNum.Text.Trim();//图纸号
                    string[] str1 = strDRAWING.Split(new string[] { "\r\n" }, StringSplitOptions.None);
                    if (str1[0].Length > 0)
                    {
                        sbDRAWING.AppendFormat(" AND PartNumber IN('{0}') ", string.Join("','", str1.ToArray()));
                    }
                    else
                    {
                        sbDRAWING.AppendFormat("");
                    }
                    string sqlDRAWING = string.IsNullOrEmpty(sbDRAWING.ToString()) ? " and PartNumber like '%%'" : sbDRAWING.ToString();
                    string sql = @"select [PartNumber]
      ,[DrawNum]
      ,[Width_1]
      ,[Dedth_1]
      ,[Width_2]
      ,[Dedth_2]
      ,[Tinckness]
      ,[D_Cutting_Size]
      ,[WorkCenterNumber]
      ,[Decription]
      ,[GROUP_CODE]
      ,[CountDecription]
      ,[iCount]
      ,[Cycle]
      ,[D01]
      ,[D04]
      ,[D07]
      ,[D11]
      ,[D14]
      ,[D17]
      ,[D21]
      ,[D24]
      ,[D30]
      ,[D27]
      ,[D28]
      ,[D29]
      ,[D31]
      ,[D32]
      ,[D34]
      ,[D37]
      ,[D41]
      ,[D42]
      ,[D44]
      ,[D47]
      ,[D51]
      ,[D54] from [LamexMESManager].[dbo].[B_IE_WorkTimeHistory] where 
CreateDate>='" + dateStart.Text + "' and CreateDate<='" + dateEnd.Text + "' and Flag='2'";
                    System.Data.DataTable dt = new System.Data.DataTable();
                    dt = BaseBuildSql.GetDataTableBySql(sql + sqlDRAWING);
                    gridView.DataSource = dt;
                    gridView1.BestFitColumns();
                    this.gridView1.OptionsView.ColumnAutoWidth = false;
                     SplashScreenTool.CloseSplashScreen();
                //}
            }
            catch //(Exception ex)
            {
                //DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, MessageBoxButtons.OK);
            }
            #region 前台计算
            ////一定要选择时间
            //if (string.IsNullOrEmpty(dateStart.Text))
            //{
            //    DevExpress.XtraEditors.XtraMessageBox.Show("请选择开始时间", "提示", MessageBoxButtons.OK);
            //    return;
            //}
            //if (string.IsNullOrEmpty(dateEnd.Text))
            //{
            //    DevExpress.XtraEditors.XtraMessageBox.Show("请选择结束时间", "提示", MessageBoxButtons.OK);
            //    return;
            //}

            //if (string.IsNullOrEmpty(ucEffective.Text))
            //{
            //    DevExpress.XtraEditors.XtraMessageBox.Show("请选择生效时间", "提示", MessageBoxButtons.OK);
            //    return;
            //}

            //GetSqlData gd = new GetSqlData();
            //GetOperation_Data gOperate = new GetOperation_Data();
            //C_D04 c_d04 = new C_D04();
            //C_D07 c_d07 = new C_D07();
            //C_D11 c_d11 = new C_D11();
            //C_D14 c_d14 = new C_D14();
            //C_D21 c_d21 = new C_D21();
            //C_D24 c_d24 = new C_D24();
            //C_D27 c_d27 = new C_D27();
            //C_D28 c_d28 = new C_D28();
            //C_D29 c_d29 = new C_D29();
            //C_D30 c_d30 = new C_D30();
            //C_D31 c_d31 = new C_D31();
            //C_D32 c_d32 = new C_D32();
            //C_D34 c_d34 = new C_D34();
            //C_D37 c_d37 = new C_D37();
            //C_D41 c_d41 = new C_D41();
            //C_D42 c_d42 = new C_D42();
            //C_Routing_Group c_routing = new C_Routing_Group();
            //GetWorkHourTable dt = new GetWorkHourTable();
            //StringBuilder sbDRAWING = new StringBuilder();
            //// StringBuilder sbPartNumber = new StringBuilder();
            //string strDRAWING = txtDrawNum.Text.Trim();//图纸号
            //string[] str1 = strDRAWING.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            //if (str1[0].Length > 0)
            //{
            //    sbDRAWING.AppendFormat(" AND A.PartNumber IN('{0}') ", string.Join("','", str1.ToArray()));
            //}
            //else
            //{
            //    sbDRAWING.AppendFormat("");
            //}
            ////string strPartNumber = txtPART_NO.Text.Trim();//部件号
            ////string[] str2 = strPartNumber.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            ////if (str2[0].Length > 0)
            ////{
            ////    sbPartNumber.AppendFormat(" AND A.PartNumber IN('{0}') ", string.Join("','", str2.ToArray()));
            ////}
            ////else
            ////{
            ////    sbPartNumber.AppendFormat("");
            ////}
            //string strPartNumber = "";
            //string strStartTime = dateStart.Text.Trim();//开始时间
            //string strEndTime = dateEnd.Text.Trim();//结束时间
            //string strEffective = ucEffective.Text.Trim();//生效时间
            //int Serial = 0, Routing_Group = 0, Calculate = 0;//代码组和流水号计数
            //List<double> RoutingList = new List<double>();//代码组描述
            //bool first = true;//用于判断是否第一次执行
            //string Routing_dec = "";
            //double TD01 = 0, TD04 = 0, TD07 = 0, TD11 = 0, TD14 = 0, TD17 = 0, TD21 = 0, TD24 = 0,
            //        TD27 = 0, TD28 = 0, TD29 = 0, TD30 = 0, TD31 = 0, TD32 = 0, TD34 = 0, TD37 = 0,
            //        TD41 = 0, TD42 = 0, TD44 = 0, TD47 = 0, TD51 = 0, TD54 = 0;
            //string Machine_flag11 = "0", Machine_flag21 = "0", Machine_flag32 = "0", Machine_flag30 = "0";
            //using (DevExpress.Utils.WaitDialogForm wdf = new DevExpress.Utils.WaitDialogForm("请稍等", "正在查询数据......", new Size(400, 80)))
            //{
            //    try
            //    {
            //        DataTable dtall = gd.GetSJSql(strPartNumber, sbDRAWING.ToString(), strStartTime, strEndTime);//获取所有SJ部件号数据             
            //        DataTable dtOperational = gOperate.GetOperationSql(strEffective);//获取工序动作对应的单位工时--增加生效时间
            //        DataTable dtFactor = gOperate.GetFactor(strEffective);//获取宽放系数--增加生效时间
            //        DataTable dtMachine = gOperate.GetMachineData(cbeMachineVer.Text);//获取机器数据
            //        DataTable dtNew = dt.GetTable_New();//定义-动态生成输出表
            //        DataRow dr = dtNew.NewRow();//定义-动态生成输出行
            //        DataTable dtRouting = c_routing.GetTable_Routing();//工艺路线流水号输出表
            //        DataRow drRouting = dtRouting.NewRow();//路线代码组输出表
            //        DataTable dtSerial = gOperate.GetRouting();
            //        DataRow drser = dtSerial.Select("1=1", "IDNO ASC").LastOrDefault();//主表最后一行数据
            //        if (dtall.Rows.Count == 0)
            //        {
            //            DevExpress.XtraEditors.XtraMessageBox.Show("查无数据，请确认是否有录入特征！", "提示", MessageBoxButtons.OK);
            //            return;
            //        }
            //        if (dtall.Rows.Count > 0)
            //        {
            //            for (int j = 0; j < dtall.Rows.Count; j++)
            //            {
            //                string[] ListRouting = dtall.Rows[j]["routing"].ToString().Split('-');//得到图纸的工艺路线
            //                #region 插入行
            //                dr = dtNew.NewRow();
            //                dr["PART_NUMBER"] = dtall.Rows[j]["PartNumber"].ToString();//部件号
            //                dr["DRAWING_NUMBER"] = dtall.Rows[j]["Drawing_Num"].ToString();//图纸号
            //                dr["Width_1"] = dtall.Rows[j]["Width_1"].ToString();//W1
            //                dr["Depth_1"] = dtall.Rows[j]["Depth_1"].ToString();//D1
            //                dr["Width_2"] = dtall.Rows[j]["Width_2"].ToString();//W2
            //                dr["Depth_2"] = dtall.Rows[j]["Depth_2"].ToString();//D2
            //                dr["Thickness"] = dtall.Rows[j]["Thickness"].ToString();//厚度
            //                dr["D_Cutting_Size"] = dtall.Rows[j]["D_Cutting_Size"].ToString();//切割尺寸
            //                dr["WORKCENTER_NUMBER"] = dtall.Rows[j]["routing"].ToString();//工艺路线
            //                dr["DESCRIBE"] = dtall.Rows[j]["Description"].ToString();//部件描述
            //                dr["GROUP_CODE"] = dtall.Rows[j]["GROUP_CODE"].ToString();//组
            //                dr["CALCULATE_DESC"] = dtall.Rows[j]["GROUP_DEC"].ToString();//计算器描述
            //                dr["CALCULATES"] = 1;//计算器
            //                dr["WEEKS"] = 30;//周期

            //                #endregion

            //                foreach (var item in ListRouting)
            //                {
            //                    switch (item.ToString())
            //                    {
            //                        case "D01":
            //                            TD01 = 16;
            //                            dr["D01"] = TD01;
            //                            RoutingList.Add(TD01);
            //                            break;
            //                        case "D04":
            //                            TD04 = Math.Ceiling(c_d04.GetD04(dtall.Rows[j]["Width_1"].ToString(), dtall.Rows[j]["Width_2"].ToString())
            //                                * (dtFactor.Select("NUMBER='D04'").Length <= 0 ? 1 :
            //                                 1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D04'"))[0].ItemArray[1].ToString()) * 0.01));
            //                            dr["D04"] = TD04;
            //                            RoutingList.Add(TD04);
            //                            break;
            //                        case "D07":
            //                            TD07 = Math.Ceiling(c_d07.GetD07(dtall.Rows[j]["Width_1"].ToString(), dtall.Rows[j]["Width_2"].ToString())
            //                                 * (dtFactor.Select("NUMBER='D07'").Length <= 0 ? 1 :
            //                                1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D07'"))[0].ItemArray[1].ToString()) * 0.01));
            //                            dr["D07"] = TD07;
            //                            RoutingList.Add(TD07);
            //                            break;
            //                        case "D11":
            //                            if (string.IsNullOrEmpty(cbeMachineVer.Text))
            //                            {
            //                                double[] ArrayTD11 = c_d11.GetD11(dtall.Select("Drawing_Num='" + dtall.Rows[j]["Drawing_Num"].ToString() + "' and PartNumber='" + dtall.Rows[j]["PartNumber"].ToString() + "'"),
            //                                   dtOperational.Select("WORKSTATION_LIST like '%D11%'"),
            //                                    // dtMachine.Select("Part_No='" + dtall.Rows[j]["PartNumber"].ToString() + "' and Machine_Name='D11'"));
            //                                 null);//机器时间
            //                                TD11 = ArrayTD11[0];
            //                                Machine_flag11 = ArrayTD11[1].ToString() == "1" ? "PH" : "0";

            //                                dr["D11"] = Math.Ceiling(TD11 * (dtFactor.Select("NUMBER='D11'").Length <= 0 ? 1 :
            //                                   1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D11'"))[0].ItemArray[1].ToString()) * 0.01));
            //                                RoutingList.Add(Convert.ToDouble(dr["D11"]));
            //                            }
            //                            else
            //                            {
            //                                double[] ArrayTD11 = c_d11.GetD11(dtall.Select("Drawing_Num='" + dtall.Rows[j]["Drawing_Num"].ToString() + "' and PartNumber='" + dtall.Rows[j]["PartNumber"].ToString() + "'"),
            //                                    dtOperational.Select("WORKSTATION_LIST like '%D11%'"),
            //                                     dtMachine.Select("Part_No='" + dtall.Rows[j]["PartNumber"].ToString() + "' and Machine_Name='D11'"));
            //                                // 0);//机器时间
            //                                TD11 = ArrayTD11[0];
            //                                Machine_flag11 = ArrayTD11[1].ToString() == "1" ? "PH" : "0";

            //                                dr["D11"] = Math.Ceiling(TD11 * (dtFactor.Select("NUMBER='D11'").Length <= 0 ? 1 :
            //                                   1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D11'"))[0].ItemArray[1].ToString()) * 0.01));
            //                                RoutingList.Add(Convert.ToDouble(dr["D11"]));
            //                            }
            //                            break;
            //                        case "D14":
            //                            TD14 = Math.Ceiling(c_d14.GetD14(dtall.Rows[j]["Width_1"].ToString(), dtall.Rows[j]["Width_2"].ToString())
            //                                 * (dtFactor.Select("NUMBER='D14'").Length <= 0 ? 1 :
            //                                1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D14'"))[0].ItemArray[1].ToString()) * 0.01));
            //                            dr["D14"] = Math.Ceiling(TD14);
            //                            RoutingList.Add(TD14);
            //                            break;
            //                        case "D17":
            //                            TD17 = 24;
            //                            dr["D17"] = TD17;
            //                            RoutingList.Add(TD17);
            //                            break;
            //                        case "D21":
            //                            if (string.IsNullOrEmpty(cbeMachineVer.Text))
            //                            {
            //                                double[] ArrayTD21 = c_d21.GetD21(dtall.Select("Drawing_Num='" + dtall.Rows[j]["Drawing_Num"].ToString() + "' and PartNumber='" + dtall.Rows[j]["PartNumber"].ToString() + "'"),
            //                                  dtOperational.Select("WORKSTATION_LIST like '%D21%'"),
            //                                  dtall.Rows[j]["D21_Component_Type"].ToString(),
            //                                    //dtMachine.Select("Part_No='" + dtall.Rows[j]["PartNumber"].ToString() + "' and Machine_Name='D21'"));
            //                                 null);//机器时间
            //                                TD21 = ArrayTD21[0];
            //                                Machine_flag21 = ArrayTD21[1].ToString() == "1" ? "BIMA" : "0";

            //                                dr["D21"] = Math.Ceiling(TD21 * (dtFactor.Select("NUMBER='D21'").Length <= 0 ? 1 :
            //                                    1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D21'"))[0].ItemArray[1].ToString()) * 0.01));
            //                                RoutingList.Add(Convert.ToDouble(dr["D21"]));
            //                            }
            //                            else
            //                            {
            //                                double[] ArrayTD21 = c_d21.GetD21(dtall.Select("Drawing_Num='" + dtall.Rows[j]["Drawing_Num"].ToString() + "' and PartNumber='" + dtall.Rows[j]["PartNumber"].ToString() + "'"),
            //                                   dtOperational.Select("WORKSTATION_LIST like '%D21%'"),
            //                                   dtall.Rows[j]["D21_Component_Type"].ToString(),
            //                                     dtMachine.Select("Part_No='" + dtall.Rows[j]["PartNumber"].ToString() + "' and Machine_Name='D21'"));
            //                                // 0);//机器时间
            //                                TD21 = ArrayTD21[0];
            //                                Machine_flag21 = ArrayTD21[1].ToString() == "1" ? "BIMA" : "0";

            //                                dr["D21"] = Math.Ceiling(TD21 * (dtFactor.Select("NUMBER='D21'").Length <= 0 ? 1 :
            //                                    1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D21'"))[0].ItemArray[1].ToString()) * 0.01));
            //                                RoutingList.Add(Convert.ToDouble(dr["D21"]));
            //                            }
            //                            break;
            //                        case "D24":
            //                            TD24 = Math.Ceiling(c_d24.GetD24(dtall.Select("Drawing_Num='" + dtall.Rows[j]["Drawing_Num"].ToString() + "' and PartNumber='" + dtall.Rows[j]["PartNumber"].ToString() + "'"),
            //                                dtOperational.Select("WORKSTATION_LIST like '%D24%'"))
            //                                 * (dtFactor.Select("NUMBER='D24'").Length <= 0 ? 1 :
            //                                1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D24'"))[0].ItemArray[1].ToString()) * 0.01));
            //                            dr["D24"] = TD24;
            //                            RoutingList.Add(TD24);
            //                            break;
            //                        case "D27":
            //                            TD27 = Math.Ceiling(c_d27.GetD27(dtall.Select("Drawing_Num='" + dtall.Rows[j]["Drawing_Num"].ToString() + "' and PartNumber='" + dtall.Rows[j]["PartNumber"].ToString() + "'"),
            //                                dtOperational.Select("WORKSTATION_LIST like '%D27%'"))
            //                                * (dtFactor.Select("NUMBER='D27'").Length <= 0 ? 1 :
            //                                1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D27'"))[0].ItemArray[1].ToString()) * 0.01));
            //                            dr["D27"] = TD27;
            //                            RoutingList.Add(TD27);
            //                            break;
            //                        case "D28":
            //                            TD28 = Math.Ceiling(c_d28.GetD28(dtall.Rows[j]["Width_1"].ToString(), dtall.Rows[j]["Width_2"].ToString(), dtall.Rows[j]["D28_Sealing_Diagonal_Edge"].ToString())
            //                                 * (dtFactor.Select("NUMBER='D28'").Length <= 0 ? 1 :
            //                                1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D28'"))[0].ItemArray[1].ToString()) * 0.01));
            //                            dr["D28"] = TD28;
            //                            RoutingList.Add(TD28);
            //                            break;
            //                        case "D29":
            //                            TD29 = Math.Ceiling(c_d29.GetD29(dtall.Rows[j]["Width_1"].ToString(), dtall.Rows[j]["Width_2"].ToString(), dtall.Rows[j]["D29_Seal_Straight_Line_Edge"].ToString())
            //                                 * (dtFactor.Select("NUMBER='D29'").Length <= 0 ? 1 :
            //                                1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D29'"))[0].ItemArray[1].ToString()) * 0.01));
            //                            dr["D29"] = TD29;
            //                            RoutingList.Add(TD29);
            //                            break;
            //                        case "D30":
            //                            double[] ArrayTD30 = c_d30.GetD30(dtall.Select("Drawing_Num='" + dtall.Rows[j]["Drawing_Num"].ToString() + "' and PartNumber='" + dtall.Rows[j]["PartNumber"].ToString() + "'"),
            //                                dtOperational.Select("WORKSTATION_LIST like '%D30%'"),
            //                                //Convert.ToDouble(gOperate.GetMachineData("D11", dtall.Rows[j]["PartNumber"].ToString()).Rows[0][0].ToString())
            //                               0);//机器时间
            //                            TD30 = ArrayTD30[0];
            //                            Machine_flag30 = ArrayTD30[1].ToString();
            //                            dr["D30"] = Math.Ceiling(TD30 * (dtFactor.Select("NUMBER='D30'").Length <= 0 ? 1 :
            //                               1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D30'"))[0].ItemArray[1].ToString()) * 0.01));
            //                            RoutingList.Add(Convert.ToDouble(dr["D30"]));
            //                            break;
            //                        case "D31":
            //                            TD31 = Math.Ceiling(c_d31.GetD31(dtall.Rows[j]["Width_1"].ToString(), dtall.Rows[j]["Width_2"].ToString(), dtall.Rows[j]["D31_Seal_Straight_Line_Edge"].ToString())
            //                                 * (dtFactor.Select("NUMBER='D31'").Length <= 0 ? 1 :
            //                                1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D31'"))[0].ItemArray[1].ToString()) * 0.01));
            //                            dr["D31"] = TD31;
            //                            RoutingList.Add(TD31);
            //                            break;
            //                        case "D32":
            //                            double[] ArrayTD32 = c_d32.GetD32(dtall.Select("Drawing_Num='" + dtall.Rows[j]["Drawing_Num"].ToString() + "' and PartNumber='" + dtall.Rows[j]["PartNumber"].ToString() + "'"),
            //                               dtOperational.Select("WORKSTATION_LIST like '%D32%'"),
            //                               dtall.Rows[j]["D32_Component_Type"].ToString(),
            //                                //  Convert.ToDouble(gOperate.GetMachineData("D32", dtall.Rows[j]["PartNumber"].ToString()).Rows[0][0].ToString())//机器时间
            //                            0);//暂时取0
            //                            TD32 = ArrayTD32[0] * 1.5;
            //                            Machine_flag32 = ArrayTD32[1].ToString();

            //                            dr["D32"] = Math.Ceiling(TD32 * (dtFactor.Select("NUMBER='D32'").Length <= 0 ? 1 :
            //                            1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D32'"))[0].ItemArray[1].ToString()) * 0.01));
            //                            RoutingList.Add(Convert.ToDouble(dr["D32"]));
            //                            break;
            //                        case "D34":
            //                            TD34 = Math.Ceiling(c_d34.GetD34(dtall.Select("Drawing_Num='" + dtall.Rows[j]["Drawing_Num"].ToString() + "' and PartNumber='" + dtall.Rows[j]["PartNumber"].ToString() + "'"),
            //                                dtOperational.Select("WORKSTATION_LIST like '%D34%'"),
            //                                dtall.Rows[j]["D34_Component_Type"].ToString(),
            //                                dtall.Rows[j]["D34_Edge_Thickness"].ToString())
            //                                 * (dtFactor.Select("NUMBER='D34'").Length <= 0 ? 1 :
            //                                 1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D34'"))[0].ItemArray[1].ToString()) * 0.01));
            //                            dr["D34"] = TD34;
            //                            RoutingList.Add(TD34);
            //                            break;
            //                        case "D37":
            //                            TD37 = Math.Ceiling((c_d37.GetD37(dtall.Select("Drawing_Num='" + dtall.Rows[j]["Drawing_Num"].ToString() + "' and PartNumber='" + dtall.Rows[j]["PartNumber"].ToString() + "'"),
            //                                dtOperational.Select("WORKSTATION_LIST like '%D37%'"), dtall.Rows[j]["routing"].ToString()))
            //                                 * (dtFactor.Select("NUMBER='D37'").Length <= 0 ? 1 :
            //                                 1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D37'"))[0].ItemArray[1].ToString()) * 0.01));
            //                            dr["D37"] = TD37;
            //                            RoutingList.Add(TD37);
            //                            break;
            //                        case "D41":
            //                            TD41 = Math.Ceiling(c_d41.GetD41(dtall.Select("Drawing_Num='" + dtall.Rows[j]["Drawing_Num"].ToString() + "' and PartNumber='" + dtall.Rows[j]["PartNumber"].ToString() + "'"),
            //                                dtOperational.Select("WORKSTATION_LIST like '%D41%'"), dtall.Rows[j]["routing"].ToString())
            //                                 * (dtFactor.Select("NUMBER='D41'").Length <= 0 ? 1 :
            //                                1 + Convert.ToDouble(dtFactor.Select(("NUMBER='D41'"))[0].ItemArray[1].ToString()) * 0.01));
            //                            dr["D41"] = TD41;
            //                            RoutingList.Add(TD41);
            //                            break;
            //                        case "D42":
            //                            TD42 = Math.Ceiling(c_d42.GetD42(dtall.Rows[j]["Width_1"].ToString(),
            //                                dtall.Rows[j]["Width_2"].ToString(),
            //                                 dtall.Rows[j]["GROUP_CODE"].ToString()));
            //                            dr["D42"] = TD42;
            //                            RoutingList.Add(TD42);
            //                            break;
            //                    }
            //                }
            //                #region 工艺代码组赋值
            //                if (RoutingList.Count == 0)
            //                {
            //                    DevExpress.XtraEditors.XtraMessageBox.Show("该部件号:" + dtall.Rows[j]["PartNumber"].ToString() + "无工艺路线简码，请检测确认！", "提示", MessageBoxButtons.OK);
            //                    return;
            //                }
            //                foreach (var list in RoutingList)
            //                {
            //                    Routing_dec += list + "_";
            //                }
            //                dr["CALCULATE_DESC"] = dtall.Rows[j]["GROUP_CODE"].ToString() + "_" + Routing_dec.Substring(0, Routing_dec.Length - 1);//代码组描述
            //                //获取计数流水和组别
            //                // int[] routings = c_routing.GetNumber(dr["CALCULATE_DESC"].ToString());

            //                //后台插入
            //                //List<string> lst1 = new List<string>();
            //                //lst1.Add(dr["CALCULATE_DESC"].ToString());//物料代码
            //                //DataTable dtTemp = Lamex.Base.BaseBuildSql.GetProDataTable("p_IE_Routing_Calculate", lst1);
            //                //dr["GROUP_CODE"] = dtTemp.Rows[0]["Routing_Group"];
            //                //dr["CALCULATES"] = dtTemp.Rows[0]["Calculate"];


            //                //DataRow drser = dtSerial.Select("1=1", "IDNO ASC").LastOrDefault();//主表最后一行数据
            //                DataRow drTemp = dtRouting.Select("1=1", "Serial ASC").LastOrDefault();//临时表最后一行数据
            //                drRouting = dtRouting.NewRow();//路线代码组输出表   
            //                DataRow[] drTemp2 = dtSerial.Select("Calculate_Desc='" + dr["CALCULATE_DESC"] + "'");//主表
            //                DataRow[] drTemp1 = dtRouting.Select("Calculate_Desc='" + dr["CALCULATE_DESC"] + "'");//临时表
            //                if (drTemp2.Length > 0)
            //                {

            //                    dr["GROUP_CODE"] = drTemp2[0]["Routing_Group"];
            //                    dr["CALCULATES"] = drTemp2[0]["Calculate"];
            //                }
            //                else
            //                {
            //                    if (drTemp1.Length > 0)
            //                    {

            //                        dr["GROUP_CODE"] = drTemp1[0]["Routing_Group"];
            //                        dr["CALCULATES"] = drTemp1[0]["Calculate"];

            //                    }
            //                    else
            //                    {
            //                        if (first)
            //                        {
            //                            Serial = 1;
            //                            if (drser != null)
            //                            {
            //                                if (Convert.ToInt32(drser["Calculate"]) >= 2 && Convert.ToInt32(drser["Calculate"]) < 99)
            //                                {
            //                                    drRouting["Routing_Group"] = Convert.ToInt32(drser["Routing_Group"]);
            //                                    drRouting["Calculate"] = Convert.ToInt32(drser["Calculate"]) + 1;

            //                                }
            //                                else if (Convert.ToInt32(drser["Calculate"]) == 99)
            //                                {
            //                                    drRouting["Routing_Group"] = Convert.ToInt32(drser["Routing_Group"]) + 1;
            //                                    drRouting["Calculate"] = 2;
            //                                }
            //                            }
            //                            else
            //                            {
            //                                drRouting["Routing_Group"] = 44000001;
            //                                drRouting["Calculate"] = 2;
            //                            }
            //                            dr["GROUP_CODE"] = drRouting["Routing_Group"];
            //                            dr["CALCULATES"] = drRouting["Calculate"];
            //                            Routing_Group = Convert.ToInt32(drRouting["Routing_Group"]);
            //                            Calculate = Convert.ToInt32(drRouting["Calculate"]);
            //                        }
            //                        else
            //                        {
            //                            Serial = Convert.ToInt32(drTemp["Serial"]) + 1;
            //                            if (drTemp != null)
            //                            {
            //                                if (Convert.ToInt32(drTemp["Calculate"]) >= 2 && Convert.ToInt32(drTemp["Calculate"]) < 99)
            //                                {
            //                                    drRouting["Routing_Group"] = Convert.ToInt32(drTemp["Routing_Group"]);
            //                                    drRouting["Calculate"] = Convert.ToInt32(drTemp["Calculate"]) + 1;

            //                                }
            //                                else if (Convert.ToInt32(drTemp["Calculate"]) == 99)
            //                                {
            //                                    drRouting["Routing_Group"] = Convert.ToInt32(drTemp["Routing_Group"]) + 1;
            //                                    drRouting["Calculate"] = 2;
            //                                }
            //                            }
            //                            else
            //                            {
            //                                drRouting["Routing_Group"] = 44000001;
            //                                drRouting["Calculate"] = 2;
            //                            }
            //                            dr["GROUP_CODE"] = drRouting["Routing_Group"];
            //                            dr["CALCULATES"] = drRouting["Calculate"];
            //                            Routing_Group = Convert.ToInt32(drRouting["Routing_Group"]);
            //                            Calculate = Convert.ToInt32(drRouting["Calculate"]);
            //                        }
            //                        //}
            //                        //存在的数据不需要插入到数据库
            //                        // drRouting = dtRouting.NewRow();//路线代码组输出表                     
            //                        drRouting["Serial"] = Serial;
            //                        drRouting["Routing_Group"] = Routing_Group;
            //                        drRouting["Calculate"] = Calculate;
            //                        drRouting["Calculate_Desc"] = dr["CALCULATE_DESC"];
            //                        drRouting["Date_TS"] = DateTime.Now;
            //                        dtRouting.Rows.Add(drRouting);
            //                        first = false;
            //                    }
            //                }
            //                #endregion
            //                dr["Machine_Flag"] = Machine_flag11 + "," + Machine_flag21 + "," + Machine_flag32;
            //                dtNew.Rows.Add(dr);
            //                #region 插入临时表后数据全部初始化为0
            //                TD01 = 0;
            //                TD04 = 0;
            //                TD07 = 0;
            //                TD11 = 0;
            //                TD14 = 0;
            //                TD17 = 0;
            //                TD21 = 0;
            //                TD24 = 0;
            //                TD27 = 0;
            //                TD28 = 0;
            //                TD29 = 0;
            //                TD30 = 0;
            //                TD31 = 0;
            //                TD32 = 0;
            //                TD34 = 0;
            //                TD37 = 0;
            //                TD41 = 0;
            //                TD42 = 0;
            //                TD44 = 0;
            //                TD47 = 0;
            //                TD51 = 0;
            //                TD54 = 0;
            //                Machine_flag11 = "0";
            //                Machine_flag21 = "0";
            //                Machine_flag32 = "0";
            //                Machine_flag30 = "0";
            //                RoutingList = new List<double>();
            //                Routing_dec = "";
            //                Serial = 0;
            //                Routing_Group = 0;
            //                Calculate = 0;
            //                #endregion
            //            }
            //        }

            //        //工艺路线流水号批量插入主表-B_IE_Calculator_Routing
            //        if (BaseBuildSql.ExcuteInsert(dtRouting, "B_IE_Calculator_Routing"))
            //        {

            //            dtRouting = new DataTable();
            //        }
            //        //绑定前重新定义列名，方便IE导出上传
            //        gridView.DataSource = dtNew;
            //        gridView1.BestFitColumns();
            //        this.gridView1.OptionsView.ColumnAutoWidth = false;
            //        base.DoView(sender);
            //        //清空输入框
            //        // txtPartNum.Text = "";
            //        txtDrawNum.Text = "";
            //    }
            //    catch
            //    {
            //    }
            //}
            #endregion
            #region 调用存储过程
            //using (DevExpress.Utils.WaitDialogForm wdf = new DevExpress.Utils.WaitDialogForm("请稍等", "正在查询数据......", new Size(400, 80)))
            //{

            //    List<string> lst = new List<string>();
            //    lst.Add(txtDrawNum.Text);
            //    //lst.Add(txtPartNum.Text.ToString());
            //    lst.Add(dateStart.UcEditValue.ToString());
            //    lst.Add(dateEnd.UcEditValue.ToString());
            //    lst.Add(ucEffective.UcEditValue.ToString());
            //    DataTable dt = Lamex.Base.BaseBuildSql.GetProDataTable("p_IE_WorkHoursCalculates", lst);

            //    gridView.DataSource = dt;
            //    gridView1.BestFitColumns();
            //    this.gridView1.OptionsView.ColumnAutoWidth = false;
            //    base.DoView(sender);
            //}
            #endregion
        }
        public override void DoExport(IButtonInfo sender)
        {
            //#region 导出方法1
            //try
            //{
            //    SaveFileDialog dlg = new SaveFileDialog();
            //    //dlg.Filter = "PDF file(*.pdf)|*.pdf";
            //    dlg.Filter = "Excel文件(*.xls)|*.xls";
            //    DialogResult dialogResult = dlg.ShowDialog(this);
            //    if (dialogResult == DialogResult.OK)
            //    {
            //        gridView1.ExportToXls(dlg.FileName);
            //        DevExpress.XtraEditors.XtraMessageBox.Show("导出成功", "提示", MessageBoxButtons.OK);
            //    }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
            //#endregion

            //导出方法2
            //if (gridView1.DataRowCount < 0) return;
            //ExportToExcel(gridView1, "SJ工时计算");
            //base.DoExport(sender);

            //导出方法3
            if (!Directory.Exists(@"C:\SAPTEMP"))
                Directory.CreateDirectory(@"C:\SAPTEMP");
            SaveFileDialog fileDialog = new SaveFileDialog();
            fileDialog.Title = "导出txt";
            fileDialog.InitialDirectory = @"C:\SAPTEMP";//导出默认路径
            fileDialog.Filter = "Txt文件(*.txt)|*.txt";//导出默认格式
            fileDialog.FileName = "ZPYX_UPLOAD";//导出默认名称
            DialogResult dialogResult = fileDialog.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
                if (gridView1.DataRowCount <= 0) return;
                List<string> list1 = new List<string>();
                StringBuilder s1 = new StringBuilder();
                System.Data.DataTable dt = (gridView1.DataSource as System.Data.DataView).Table;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    list1.Add(dt.Rows[i]["PartNumber"].ToString());
                }
                s1.AppendFormat(@" AND PartNumber IN ('{0}')", string.Join("','", list1.ToArray()));
                string sql = @" SELECT 
       [PartNumber] as '部件/组件'
      ,[Decription] as '描述'
      ,[GROUP_CODE] as '组'
      ,[CountDecription] as '计数器描述'
      ,[iCount] as '计数器'
      ,[Cycle] as '周期(H)'
      ,[D01] as 'D01_主线-自动仓库'
      ,[D04] as 'D04_主线-开料LS1'
      ,[D07] as 'D07_主线-COMBIMA'
      ,[D11] as 'D11_主线-钻孔P&H'
      ,[D14] as 'D14_主线-开料FH4'
      ,[D17] as 'D17_主线-翻板机'
      ,[D21] as 'D21_主线-BIMA'
      ,[D24] as 'D24_小板线'
      ,[D30] as 'D30_斜边线-数控钻'
      ,[D27] as 'D27_主线装配区'
      ,[D28] as 'D28_斜边线-斜封边'
      ,[D29] as 'D29_斜边线-直封边'
      ,[D31] as 'D31_异型线-直封边'
      ,[D32] as 'D32_斜边线-CNC'
      ,[D34] as 'D34_异型线-手工封边'
      ,[D37] as 'D37_异型线-毛刷组装'
      ,[D41] as 'D41_木工加工区'
      ,[D42] as 'D42_配套区'
      ,[D44] as 'D44_柜桶组装'
      ,[D47] as 'D47_柜子组装'
      ,[D51] as 'D51_包装'
      ,[D54] as 'D54_配件包装'     
  FROM [LamexMESManager].[dbo].[B_IE_WorkTimeHistory]
  where 1=1 " + s1.ToString() + "";

                DataTable dtList = BaseBuildSql.GetDataTableBySql(sql);

                GridControl grid = new GridControl();
                GridView view = new GridView();
                grid.ViewCollection.Add(view);
                grid.MainView = view;
                view.GridControl = grid;
                foreach (DataColumn dc in dtList.Columns)
                {
                    DevExpress.XtraGrid.Columns.GridColumn gridColumnNumber = view.Columns.AddVisible(dc.ColumnName);
                    gridColumnNumber.FieldName = dc.ColumnName;
                }
                grid.DataSource = dtList;
                this.Controls.Add(grid);
                grid.ForceInitialize();
                view.BestFitColumns();
                //view.OptionsPrint.PrintHorzLines = false;
                //view.OptionsPrint.PrintVertLines = false;
                view.ExportToText(fileDialog.FileName);
                // DevExpress.XtraEditors.XtraMessageBox.Show("导出成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (DevExpress.XtraEditors.XtraMessageBox.Show("导出成功，是否打开文件？", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    System.Diagnostics.Process.Start(fileDialog.FileName);//打开指定路径下的文件

            }
        }
        public void ExportToExcel(GridView gridView, string 文件名)
        {
            System.Data.DataTable dt = (gridView.DataSource as System.Data.DataView).Table;
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "Excel文件(*.xls)|*.xls";
            dlg.FilterIndex = 0;
            dlg.RestoreDirectory = true;            //dlg.CreatePrompt = true;            
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            dlg.FileName = string.Format("{0}_{1}", DateTime.Now.ToString("yyyy-MM-dd HH时mm分"), 文件名);
            if (dlg.ShowDialog() != DialogResult.OK) return;
            string filePath = dlg.FileName;
            using (DevExpress.Utils.WaitDialogForm wdf = new DevExpress.Utils.WaitDialogForm("请稍等", "正在导出数据...", new Size(400, 80)))
            {
                int OLDOFFICEVESION = -4143;
                int NEWOFFICEVESION = 56;                //保存excel文件的格式                
                int FormatNum;                //excel版本号                string Version;                //启动应用                
                Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                Microsoft.Office.Interop.Excel.Workbooks workbooks = xlApp.Workbooks;                //创建文件                
                Microsoft.Office.Interop.Excel.Workbook workbook = workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);                //创建sheet                
                Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1];                //获取你使用的excel 的版本号                
                Version = xlApp.Version;                //使用Excel 97-2003                
                if (Convert.ToDouble(value: Version) < 12)
                {
                    FormatNum = OLDOFFICEVESION;
                }                //使用 excel 2007或更新                
                else
                {
                    FormatNum = NEWOFFICEVESION;
                }
                //添加输出excel表格的表头信息信息                
                //注意这里的excel对应的单元格第一个位置为[1,1]，而不是我们平时定义[0,0]                
                for (int i = 0; i < gridView.Columns.Count; i++)
                {
                    worksheet.Cells[1, i + 1] = gridView.Columns[i].FieldName;
                }
                //添加输出excel表格的内容信息                
                for (int rowIndex = 1; rowIndex < dt.Rows.Count + 1; rowIndex++)
                {
                    DataRow rowArr = dt.Rows[rowIndex - 1];
                    for (int cellIndex = 0; cellIndex < gridView.Columns.Count; cellIndex++)
                    {
                        string aa = rowArr[cellIndex].ToString();
                        worksheet.Cells[rowIndex + 1, cellIndex + 1] = rowArr[gridView.Columns[cellIndex].FieldName];
                    }
                }
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, 2]).EntireColumn.Delete(0);
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, 2]).EntireColumn.Delete(0);
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, 2]).EntireColumn.Delete(0);
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, 2]).EntireColumn.Delete(0);
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, 2]).EntireColumn.Delete(0);
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, 2]).EntireColumn.Delete(0);
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, 2]).EntireColumn.Delete(0);
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, 2]).EntireColumn.Delete(0);
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, 2]).EntireColumn.Delete(0);
                ((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, 2]).EntireColumn.Delete(0);
                //((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, 2]).EntireColumn.Delete(0);
                //删除已存在的excel文件，否则会无法保存创建的excel文件                
                if (File.Exists(filePath))
                {
                    try
                    {
                        File.Delete(filePath);
                    }
                    catch (IOException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
                //保存，这里必须指定FormatNum文件的格式，否则无法打开创建的excel文件                
                workbook.SaveAs(filePath, FormatNum);
                //显示创建的excel文件，true打开Excel，false隐藏Excel                
                xlApp.Visible = false;                //关闭Excel进程                
                xlApp.Quit();
            }

        }
        #region"保存"
        public override void DoSave(IButtonInfo sender)
        {
            #region 按钮权限
            if (!BuildSqlHelper.IsExistList("B_IE_WorkTimeHistory", "LamexMESManager")) return;
            #endregion
            //try
            //{
            //    using (DevExpress.Utils.WaitDialogForm wdf = new DevExpress.Utils.WaitDialogForm("请稍等", "正在保存数据...", new Size(400, 80)))
            //    {
            //        Lamex.SIESystemManager.Model.B_IE_WorkTimeHistoryInfo workModel = new Model.B_IE_WorkTimeHistoryInfo();
            //        for (int i = 0; i < gridView1.RowCount; i++)
            //        {
            //            B_IE_WorkTimeHistoryInfo model = BaseFactory<B_IE_WorkTimeHistory>.Instance.GetEntriyList("1=1 and PartNumber='" + gridView1.GetRowCellDisplayText(i, "PART_NUMBER").ToString() + "'").FirstOrDefault();
            //            if (model == null)
            //            {
            //                workModel.PartNumber = gridView1.GetRowCellDisplayText(i, "PART_NUMBER").ToString();
            //                workModel.DrawNum = gridView1.GetRowCellDisplayText(i, "DRAWING_NUMBER").ToString();
            //                workModel.Width_1 = gridView1.GetRowCellDisplayText(i, "Width_1").ToString();
            //                workModel.Dedth_1 = gridView1.GetRowCellDisplayText(i, "Depth_1").ToString();
            //                workModel.Width_2 = gridView1.GetRowCellDisplayText(i, "Width_2").ToString();
            //                workModel.Dedth_2 = gridView1.GetRowCellDisplayText(i, "Depth_2").ToString();
            //                workModel.Tinckness = gridView1.GetRowCellDisplayText(i, "Thickness").ToString();
            //                workModel.D_Cutting_Size = gridView1.GetRowCellDisplayText(i, "D_Cutting_Size").ToString();
            //                workModel.WorkCenterNumber = gridView1.GetRowCellDisplayText(i, "WORKCENTER_NUMBER").ToString();
            //                workModel.Decription = gridView1.GetRowCellDisplayText(i, "DESCRIBE").ToString();
            //                workModel.GROUP_CODE = gridView1.GetRowCellDisplayText(i, "GROUP_CODE").ToString();
            //                workModel.CountDecription = gridView1.GetRowCellDisplayText(i, "CALCULATE_DESC").ToString();
            //                workModel.iCount = gridView1.GetRowCellDisplayText(i, "CALCULATES").ToString();
            //                workModel.Cycle = gridView1.GetRowCellDisplayText(i, "WEEKS").ToString();
            //                workModel.D01 = gridView1.GetRowCellDisplayText(i, "D01").ToString();
            //                workModel.D04 = gridView1.GetRowCellDisplayText(i, "D04").ToString();
            //                workModel.D07 = gridView1.GetRowCellDisplayText(i, "D07").ToString();
            //                workModel.D11 = gridView1.GetRowCellDisplayText(i, "D11").ToString();
            //                workModel.D14 = gridView1.GetRowCellDisplayText(i, "D14").ToString();
            //                workModel.D17 = gridView1.GetRowCellDisplayText(i, "D17").ToString();
            //                workModel.D21 = gridView1.GetRowCellDisplayText(i, "D21").ToString();
            //                workModel.D24 = gridView1.GetRowCellDisplayText(i, "D24").ToString();
            //                workModel.D30 = gridView1.GetRowCellDisplayText(i, "D30").ToString();
            //                workModel.D27 = gridView1.GetRowCellDisplayText(i, "D27").ToString();
            //                workModel.D28 = gridView1.GetRowCellDisplayText(i, "D28").ToString();
            //                workModel.D29 = gridView1.GetRowCellDisplayText(i, "D29").ToString();
            //                workModel.D31 = gridView1.GetRowCellDisplayText(i, "D31").ToString();
            //                workModel.D32 = gridView1.GetRowCellDisplayText(i, "D32").ToString();
            //                workModel.D34 = gridView1.GetRowCellDisplayText(i, "D34").ToString();
            //                workModel.D37 = gridView1.GetRowCellDisplayText(i, "D37").ToString();
            //                workModel.D41 = gridView1.GetRowCellDisplayText(i, "D41").ToString();
            //                workModel.D42 = gridView1.GetRowCellDisplayText(i, "D42").ToString();
            //                workModel.D44 = gridView1.GetRowCellDisplayText(i, "D44").ToString();
            //                workModel.D47 = gridView1.GetRowCellDisplayText(i, "D47").ToString();
            //                workModel.D51 = gridView1.GetRowCellDisplayText(i, "D51").ToString();
            //                workModel.D54 = gridView1.GetRowCellDisplayText(i, "D54").ToString();
            //                workModel.CreateDate = DateTime.Now;
            //                workModel.Flag = "2";
            //                BaseFactory<B_IE_WorkTimeHistory>.Instance.Insert(workModel);
            //            }
            //            else
            //            {
            //                model.PartNumber = gridView1.GetRowCellDisplayText(i, "PART_NUMBER").ToString();
            //                model.DrawNum = gridView1.GetRowCellDisplayText(i, "DRAWING_NUMBER").ToString();
            //                model.Width_1 = gridView1.GetRowCellDisplayText(i, "Width_1").ToString();
            //                model.Dedth_1 = gridView1.GetRowCellDisplayText(i, "Depth_1").ToString();
            //                model.Width_2 = gridView1.GetRowCellDisplayText(i, "Width_2").ToString();
            //                model.Dedth_2 = gridView1.GetRowCellDisplayText(i, "Depth_2").ToString();
            //                model.Tinckness = gridView1.GetRowCellDisplayText(i, "Thickness").ToString();
            //                model.D_Cutting_Size = gridView1.GetRowCellDisplayText(i, "D_Cutting_Size").ToString();
            //                model.WorkCenterNumber = gridView1.GetRowCellDisplayText(i, "WORKCENTER_NUMBER").ToString();
            //                model.Decription = gridView1.GetRowCellDisplayText(i, "DESCRIBE").ToString();
            //                model.GROUP_CODE = gridView1.GetRowCellDisplayText(i, "GROUP_CODE").ToString();
            //                model.CountDecription = gridView1.GetRowCellDisplayText(i, "CALCULATE_DESC").ToString();
            //                model.iCount = gridView1.GetRowCellDisplayText(i, "CALCULATES").ToString();
            //                model.Cycle = gridView1.GetRowCellDisplayText(i, "WEEKS").ToString();
            //                model.D01 = gridView1.GetRowCellDisplayText(i, "D01").ToString();
            //                model.D04 = gridView1.GetRowCellDisplayText(i, "D04").ToString();
            //                model.D07 = gridView1.GetRowCellDisplayText(i, "D07").ToString();
            //                model.D11 = gridView1.GetRowCellDisplayText(i, "D11").ToString();
            //                model.D14 = gridView1.GetRowCellDisplayText(i, "D14").ToString();
            //                model.D17 = gridView1.GetRowCellDisplayText(i, "D17").ToString();
            //                model.D21 = gridView1.GetRowCellDisplayText(i, "D21").ToString();
            //                model.D24 = gridView1.GetRowCellDisplayText(i, "D24").ToString();
            //                model.D30 = gridView1.GetRowCellDisplayText(i, "D30").ToString();
            //                model.D27 = gridView1.GetRowCellDisplayText(i, "D27").ToString();
            //                model.D28 = gridView1.GetRowCellDisplayText(i, "D28").ToString();
            //                model.D29 = gridView1.GetRowCellDisplayText(i, "D29").ToString();
            //                model.D31 = gridView1.GetRowCellDisplayText(i, "D31").ToString();
            //                model.D32 = gridView1.GetRowCellDisplayText(i, "D32").ToString();
            //                model.D34 = gridView1.GetRowCellDisplayText(i, "D34").ToString();
            //                model.D37 = gridView1.GetRowCellDisplayText(i, "D37").ToString();
            //                model.D41 = gridView1.GetRowCellDisplayText(i, "D41").ToString();
            //                model.D42 = gridView1.GetRowCellDisplayText(i, "D42").ToString();
            //                model.D44 = gridView1.GetRowCellDisplayText(i, "D44").ToString();
            //                model.D47 = gridView1.GetRowCellDisplayText(i, "D47").ToString();
            //                model.D51 = gridView1.GetRowCellDisplayText(i, "D51").ToString();
            //                model.D54 = gridView1.GetRowCellDisplayText(i, "D54").ToString();
            //                model.CreateDate = DateTime.Now;
            //                model.Flag = "2";
            //                BaseFactory<B_IE_WorkTimeHistory>.Instance.Update(model);
            //            }
            //        }

            //    }
            //    XtraMessageBox.Show("保存成功！");
            //}
            //catch (Exception ex)
            //{
            //    XtraMessageBox.Show("保存失败！");
            //}
            //base.DoSave(sender);
        }
        #endregion
    }
}